//
//  BaseTabBarController.swift
//  FearfulNotification
//
//  Created by 筱鹏 on 2017/8/24.
//  Copyright © 2017年 筱鹏. All rights reserved.
//

import UIKit

class BaseTabBarController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()
        self.configTabbarInfo()
        self.configSubViewControllers()
//        let homePage = FNHomePageViewController()
        
        // Do any additional setup after loading the view.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    
    override var preferredStatusBarStyle: UIStatusBarStyle {
        get {
            return .lightContent
        }
    }
    
    func configSubViewControllers() {
        var muVCS:[UIViewController]? = [];
        for controllerDic in TabBarControllers {
            let newClass:AnyClass? = NSClassFromString(controllerDic["controller"]!)
            guard let vcClass = newClass as? UIViewController.Type else { return }
            let vc = vcClass.init()
            let navVC = BaseNavigationController(rootViewController: vc)
            navVC.title = controllerDic["title"]
            let image = UIImage(named: controllerDic["image"]!)
            navVC.tabBarItem = UITabBarItem(title: controllerDic["title"], image: image, selectedImage: image)
            
            muVCS?.append(navVC)
        }
        self.viewControllers = muVCS
    }
    
    func configTabbarInfo() {
        self.tabBar.tintColor = Theme.color.foreground
        self.tabBar.barTintColor = Theme.color.background
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
